import { request } from './request'
// 商品模块
// 列表
export const getGoodsApi = getParamsData => { // {query pagenum pagesize}
    return request({
        url: 'goods',
        method: 'get',
        params: getParamsData
    })
}
// 删除
export const deleteGoodsApi = id => {
    // return axios.delete(`goods/:id`).then(res=>res.data)
    return request({
        url: `goods/${id}`,
        method: 'delete'
    })
}
// 添加
export const postGoodsApi = params => {// params参数同接口文档
    return request({
        url: 'goods',
        method: 'post',
        data: params
    })
}
// 编辑
export const editGoodsApi = (id, params) => {// params参数同接口文档
    console.log(params)
    return request({
        url: `goods/${id}`,
        method: 'put',
        data: params
    })
}
// 商品分类模块 START
export const getGoodsCateApi = (showLevel = 3) => { // 形参 默认3层

    return request({
        url: `categories`,
        params: { type: [showLevel] }
    })
}
export const querypIdApi = (pid) => {
    console.log(pid);

    return request({
        url: `goods/${pid}`
    })
}

// 商品分类模块 END


// 订单模块 START
export const getOrdersApi = getParamsData => { // { pagenum pagesize } 
    return request({
        url: `orders`,
        method: 'get',
        params: getParamsData
    })
}
// 订单模块 END